package com.example.computer_exam_training_sys.mapper;

import com.example.computer_exam_training_sys.vo.UserExamDTO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface UserExamMapper {
    @Select("SELECT ue.exam_id, ue.user_id, ue.paper_id, ep.paper_name, ue.user_score, ue.total_score, ue.create_time, ue.duration " +
            "FROM user_exams ue " +
            "JOIN exam_papers ep ON ue.paper_id = ep.paper_id " +
            "WHERE ue.user_id = #{userId}")
    List<UserExamDTO> getExamPapersByUserId(@Param("userId") Integer userId);

    @Select("SELECT ue.exam_id, ue.user_id, ue.paper_id, ep.paper_name, ue.user_score, ue.total_score, ue.create_time, ue.duration " +
            "FROM user_exams ue " +
            "JOIN exam_papers ep ON ue.paper_id = ep.paper_id " +
            "WHERE ue.paper_id = #{paperId}")
    List<UserExamDTO> getUserExamsByPaperId(@Param("paperId") Integer paperId);
}

